"use strict";
var Locale = require("element-ui/lib/mixins/locale");
var FileGrid = require("./components/file-grid");
var FileTable = require("./components/file-table");
var icons = require("./icons");
var license = require("../utils/license");
function _interopDefaultLegacy(e) {
  return e && typeof e === "object" && "default" in e ? e : { "default": e };
}
var Locale__default = /* @__PURE__ */ _interopDefaultLegacy(Locale);
var FileGrid__default = /* @__PURE__ */ _interopDefaultLegacy(FileGrid);
var FileTable__default = /* @__PURE__ */ _interopDefaultLegacy(FileTable);
var render = function() {
  var _vm = this;
  var _h = _vm.$createElement;
  var _c = _vm._self._c || _h;
  return _vm.authenticated ? _c("div", { staticClass: "ele-file-list-group" }, [_vm.grid ? _c("FileGrid", { attrs: { "data": _vm.data, "icons": _vm.icons, "selection": _vm.checked, "checkbox": _vm.checkbox, "checked": _vm.allChecked, "indeterminate": _vm.indeterminate, "total": _vm.checked && _vm.checked.length, "total-text": _vm.t("ele.fileList.selectTips", { total: _vm.checked.length }), "check-all-text": _vm.t("ele.fileList.selectAll") }, on: { "check-all-change": _vm.checkAllChange, "item-click": _vm.onItemClick, "item-check-change": _vm.itemCheckChange } }) : _c("FileTable", { attrs: { "data": _vm.data, "icons": _vm.icons, "selection": _vm.checked, "checkbox": _vm.checkbox, "checked": _vm.allChecked, "indeterminate": _vm.indeterminate, "total": _vm.checked && _vm.checked.length, "total-text": _vm.t("ele.fileList.selectTips", { total: _vm.checked.length }), "check-all-text": _vm.t("ele.fileList.selectAll"), "name-text": _vm.t("ele.fileList.fileName"), "size-text": _vm.t("ele.fileList.fileSize"), "time-text": _vm.t("ele.fileList.fileTimestamp"), "sort": _vm.sort, "order": _vm.order }, on: { "check-all-change": _vm.checkAllChange, "item-click": _vm.onItemClick, "item-check-change": _vm.itemCheckChange, "sort-change": _vm.onSortChange }, scopedSlots: _vm._u([{ key: "tool", fn: function(ref) {
    var item = ref.item;
    return [_vm._t("tool", null, { "item": item })];
  } }], null, true) })], 1) : _vm._e();
};
var staticRenderFns = [];
function normalizeComponent(scriptExports, render2, staticRenderFns2, functionalTemplate, injectStyles, scopeId, moduleIdentifier, shadowMode) {
  var options = typeof scriptExports === "function" ? scriptExports.options : scriptExports;
  if (render2) {
    options.render = render2;
    options.staticRenderFns = staticRenderFns2;
    options._compiled = true;
  }
  if (functionalTemplate) {
    options.functional = true;
  }
  if (scopeId) {
    options._scopeId = "data-v-" + scopeId;
  }
  var hook;
  if (moduleIdentifier) {
    hook = function(context) {
      context = context || this.$vnode && this.$vnode.ssrContext || this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext;
      if (!context && typeof __VUE_SSR_CONTEXT__ !== "undefined") {
        context = __VUE_SSR_CONTEXT__;
      }
      if (injectStyles) {
        injectStyles.call(this, context);
      }
      if (context && context._registeredComponents) {
        context._registeredComponents.add(moduleIdentifier);
      }
    };
    options._ssrRegister = hook;
  } else if (injectStyles) {
    hook = shadowMode ? function() {
      injectStyles.call(this, (options.functional ? this.parent : this).$root.$options.shadowRoot);
    } : injectStyles;
  }
  if (hook) {
    if (options.functional) {
      options._injectStyles = hook;
      var originalRender = options.render;
      options.render = function renderWithStyleInjection(h, context) {
        hook.call(context);
        return originalRender(h, context);
      };
    } else {
      var existing = options.beforeCreate;
      options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
    }
  }
  return {
    exports: scriptExports,
    options
  };
}
const __vue2_script = {
  name: "EleFileList",
  mixins: [Locale__default["default"]],
  components: { FileGrid: FileGrid__default["default"], FileTable: FileTable__default["default"] },
  props: {
    data: Array,
    checked: Array,
    grid: {
      type: Boolean,
      default: true
    },
    sort: {
      type: [String, Boolean],
      default: false
    },
    order: String,
    icons: {
      type: Array,
      default() {
        return icons.icons;
      }
    },
    smIcons: {
      type: Array,
      default() {
        return icons.smIcons;
      }
    }
  },
  emits: ["item-click", "sort-change", "update:checked"],
  data() {
    return {
      authenticated: license.checkLicense()
    };
  },
  computed: {
    checkbox() {
      return Array.isArray(this.checked);
    },
    allChecked() {
      var _a, _b, _c;
      return !!((_a = this.data) == null ? void 0 : _a.length) && ((_b = this.checked) == null ? void 0 : _b.length) === ((_c = this.data) == null ? void 0 : _c.length);
    },
    indeterminate() {
      var _a, _b;
      return ((_a = this.checked) == null ? void 0 : _a.length) !== ((_b = this.data) == null ? void 0 : _b.length);
    }
  },
  methods: {
    checkAllChange() {
      var _a;
      if (this.allChecked) {
        this.$emit("update:checked", []);
      } else {
        this.$emit("update:checked", [...(_a = this.data) != null ? _a : []]);
      }
    },
    itemCheckChange(item) {
      var _a, _b, _c, _d;
      const index2 = (_b = (_a = this.checked) == null ? void 0 : _a.indexOf(item)) != null ? _b : -1;
      if (index2 === -1) {
        this.$emit("update:checked", (_c = this.checked) == null ? void 0 : _c.concat([item]));
      } else {
        const cks = (_d = this.checked) == null ? void 0 : _d.slice(0, index2).concat(this.checked.slice(index2 + 1, this.checked.length));
        this.$emit("update:checked", cks);
      }
    },
    onItemClick(item) {
      this.$emit("item-click", item);
    },
    onSortChange(name) {
      if (typeof this.sort === "string") {
        this.$emit("sort-change", {
          sort: name,
          order: this.order && name === this.sort ? { asc: "desc", desc: "" }[this.order] : "asc"
        });
      }
    }
  }
};
const __cssModules = {};
var __component__ = /* @__PURE__ */ normalizeComponent(__vue2_script, render, staticRenderFns, false, __vue2_injectStyles, null, null, null);
function __vue2_injectStyles(context) {
  for (let o in __cssModules) {
    this[o] = __cssModules[o];
  }
}
var index = /* @__PURE__ */ function() {
  return __component__.exports;
}();
module.exports = index;
